/* GUI CONVERTED from rsgetrel.i (converter v1.76) Thu Feb 28 19:34:13 2002 */
/* rsgetrel.i - Release Management Supplier Schedules                         */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.4.1.5 $                                                       */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.3    LAST MODIFIED: 09/30/92           BY: WUG *G462*          */
/* REVISION: 7.3    LAST MODIFIED: 05/06/93           BY: WUG *GA72*          */
/* REVISION: 7.3    LAST MODIFIED: 06/21/93           BY: WUG *GC53*          */
/* REVISION: 7.3    LAST MODIFIED: 11/01/94           BY: ame *GN88*          */
/* REVISION: 7.4    LAST MODIFIED: 12/29/97           BY: jpm *H1HV*          */
/* REVISION: 8.6    LAST MODIFIED: 05/20/98           BY: *K1Q4* Alfred Tan   */
/* REVISION: 9.1    LAST MODIFIED: 03/24/00     BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00     BY: *N0KP* Mark Brown         */
/* REVISION: 9.1    LAST MODIFIED: 08/29/00     BY: *N0PM* Arul Victoria      */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.4.1.5 $    BY: Jean Miller        DATE: 02/27/02  ECO: *N1BB* */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* GETS A SCHEDULED ORDER SCHEDULE RECORD (sch_mstr) */
define variable c-msgarg as character no-undo.

find pod_det where pod_nbr = scx_order
               and pod_line = scx_line
exclusive-lock no-error.

find po_mstr where po_nbr = pod_nbr no-lock no-error.

global_schtype = schtype.
{gpbrparm.i &browse=gplu539.p &parm=c-brparm3 &val="string(global_schtype)"}

display
   "" @ sch_rlse_id
with frame a.

do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


   prompt-for sch_rlse_id with frame a no-validate editing:
      {mfnp05.i sch_mstr sch_tnlr
         "sch_type = schtype and sch_nbr = scx_order
         and sch_line = scx_line"
         sch_rlse_id "input sch_rlse_id"}

      if recno <> ? then do:
         display sch_rlse_id with frame a.
      end.
   end. /* prompt-for */

   if input sch_rlse_id = "" then do:

      if can-find(sch_mstr where
                  sch_type = schtype and
                  sch_nbr = scx_order and
                  sch_line = scx_line and
                  sch_rlse_id = pod_curr_rlse_id[schtype - 3])
      then do:
         display
            pod_curr_rlse_id[schtype - 3] @ sch_rlse_id
         with frame a.
      end.
      else do:
         /* NO ACTIVE SCHED EXISTS, ENTRY REQRD */
         {pxmsg.i &MSGNUM=8175 &ERRORLEVEL=3}
         bell.
         undo, retry.
      end.

   end. /* if input sch_rlse_id = "" */

   find sch_mstr where
        sch_type = schtype
    and sch_nbr = scx_order
    and sch_line = scx_line
    and sch_rlse_id = input sch_rlse_id
   exclusive-lock no-error.

   if available sch_mstr then do:
      if sch_rlse_id <> pod_curr_rlse_id[schtype - 3] then do:
         if pod_curr_rlse_id[schtype - 3] <> "" then do:
            c-msgarg = pod_curr_rlse_id[schtype - 3].
            /* NO ACTIVE RELEASE, ACTIVE RELEASE IS */
            {pxmsg.i &MSGNUM=6005 &ERRORLEVEL=2 &MSGARG1=c-msgarg}
         end.
      end.
      else do:
         /* MODIFYING THE ACTIVE SCHED RELEASE */
         {pxmsg.i &MSGNUM=6006 &ERRORLEVEL=1}
      end.
   end. /* if available sch_mstr */

   else do:

      /* ADDING NEW RECORD */
      {pxmsg.i &MSGNUM=1 &ERRORLEVEL=1}

      create sch_mstr.
      assign
         sch_type = schtype
         sch_nbr = scx_order
         sch_line = scx_line
         sch_rlse_id.

      if recid(sch_mstr) = -1 then .

      /* PICK UP SOME DATA ITEMS FROM PRIOR SCHEDULE */
      if pod_curr_rlse_id[schtype - 3] > "" then do:

         /* COPY DATA FROM ACTIVE SCHEDULE? */
         {pxmsg.i &MSGNUM=6007 &ERRORLEVEL=1 &CONFIRM=yn}

         if yn then do for prev_sch_mstr:

            find prev_sch_mstr where
                  sch_type = sch_mstr.sch_type
              and sch_nbr = sch_mstr.sch_nbr
              and sch_line = sch_mstr.sch_line
              and sch_rlse_id = pod_curr_rlse_id[schtype - 3]
            no-lock.

            {gprun.i ""rcsinit.p""
               "(input recid(prev_sch_mstr),
                 input recid(sch_mstr),
                 input yes)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         end. /* if yn then do */

      end. /* if pod_curr_rlse */

      assign
         sch_cr_date = today
         sch_cr_time = time
         sch_ship = po_ship
         sch_eff_start = today
         sch_eff_end = ?
         sch_sd_pat = pod_sd_pat.

   end. /* else do (ADDING NEW REC) */

end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* do on error undo */
